package com.zhike.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhike.model.ContractRview;
import com.zhike.model.LabsFlowA;
import com.zhike.model.LbtNumberType;
import com.zhike.model.Sample;
import com.zhike.model.SceneFlow;
import com.zhike.model.Users;
import com.zhike.model.WorkFlowTask;
import com.zhike.service.LaboratoryService;

@Controller
public class LaboratoryController {

	@Autowired
	LaboratoryService laboratoryService;
	
	/**
	 * 消息评审详情
	 * @param contractRview
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="api/ContractRview/detail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String ContractRviewDetail(ContractRview contractRview) {
		String string = laboratoryService.ContractRviewDetail(contractRview);
		return string;
	}
	
	/**
	 * 领取编号
	 */
	@ResponseBody
	@RequestMapping(value="api/numberGet",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String numberGet(LbtNumberType lbtNumberType) {
		String string = laboratoryService.numberGet(lbtNumberType);
		return string;
	}
	/**
	 * 根据父id 查询子列表
	 */
	@ResponseBody
	@RequestMapping(value="api/detectionStructure",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String detectionStructure (LbtNumberType lbtNumberType) {
		String string = laboratoryService.detectionStructure(lbtNumberType);
		return string;
	}
	
	/**
	 * 部门评审
	 * @param contractRview
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="api/review/submit",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String reviewSubmit (ContractRview contractRview) {
		String string = laboratoryService.reviewSubmit(contractRview);
		return string;
	}
	
	/**
	 * 领导评审
	 */
	@ResponseBody
	@RequestMapping(value="api/leadTheReview/submit",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String leadTheReview (ContractRview contractRview) {
		String string = laboratoryService.leadTheReview(contractRview);
		return string;
	}
	
	/**
	 * 合同修改的功能
	 */
	@ResponseBody
	@RequestMapping(value="api/contract/update",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String contractUpdate (WorkFlowTask workFlowTask,ContractRview contractRview) {
		String string = laboratoryService.contractUpdate(workFlowTask,contractRview);
		return string;
	}
	/**
	 * 派工详情 
	 */
	@ResponseBody
	@RequestMapping(value="api/SceneFlow/detail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String SceneFlowDetail (SceneFlow sceneFlow) {
		String string = laboratoryService.SceneFlowDetail(sceneFlow);
		return string;
	}
	
	/**
	 * 通过id比对密码是否正确
	 */
	@ResponseBody
	@RequestMapping(value="api/password/contrast",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String passWordContrast (Users users) {
		String string = laboratoryService.passWordContrast(users);
		return string;
	}
	
	/**
	 * 派工处理 接受派工 或者 不接受派工
	 */
	@ResponseBody
	@RequestMapping(value="api/work/order",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String workOrder (WorkFlowTask workFlowTask) {
		String string = laboratoryService.workOrder(workFlowTask);
		return string;
	}
	
	/**
	 * 提交报告的 提交审核
	 */
	@ResponseBody
	@RequestMapping(value="api/audit/commit",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String auditCommit (WorkFlowTask workFlowTask,SceneFlow sceneFlow) {
		String string = laboratoryService.auditCommit(workFlowTask,sceneFlow);
		return string;
	}
	
	/**
	 * 提交报告的 提交审批
	 */
	@ResponseBody
	@RequestMapping(value="api/approve/commit",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String approveCommit (WorkFlowTask workFlowTask,SceneFlow sceneFlow) {
		String string = laboratoryService.approveCommit(workFlowTask,sceneFlow);
		return string;
	}
	


	
	/**
	 * 提交的报告已完成
	 */
	@ResponseBody
	@RequestMapping(value="api/approve/over",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String approveOver (WorkFlowTask workFlowTask) {
		String string = laboratoryService.approveOver(workFlowTask);
		return string;
	}
	/**
	 * 试验修改的工程列表
	 */
	@ResponseBody
	@RequestMapping(value="api/testModifier/project",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String projectList (SceneFlow sceneFlow) {
		String string = laboratoryService.projectList(sceneFlow);
		return string;
	}
	
	/**
	 * 根据派工编号查询工程详情
	 */
	@ResponseBody
	@RequestMapping(value="api/workorder/project",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String workorderSearch (SceneFlow sceneFlow) {
		String string = laboratoryService.workorderSearch(sceneFlow);
		return string;
	}
	
	/**
	 * 试炼修改到审核
	 */
	@ResponseBody
	@RequestMapping(value="api/test/audit",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String testAudit (SceneFlow sceneFlow,WorkFlowTask workFlowTask) {
		String string = laboratoryService.testAudit(sceneFlow,workFlowTask);
		return string;
	}
	
	/**
	 * 添加样品信息
	 */
	@ResponseBody
	@RequestMapping(value="api/samplesMess/add",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String samplesMessAdd (Sample sample) {
		String string = laboratoryService.samplesMessAdd(sample);
		return string;
	}
	
	/**
	 * 样品列表
	 * @param sample
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="api/samplesMess/list",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String samplesMessList (Sample sample) {
		String string = laboratoryService.samplesMessList(sample);
		return string;
	}
	

	/**
	 * 委托收样详情
	 */
	@ResponseBody
	@RequestMapping(value="api/entrust/detail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String entrustDetail (LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
		String string = laboratoryService.entrustDetail(labsFlowA,workFlowTask);
		return string;
	}
	
	
	/**
	 * 提交试验室委托收样
	 */
	@ResponseBody
	@RequestMapping(value="api/entrust/finish",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String entrustFinish (LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
		String string = laboratoryService.entrustFinish(labsFlowA,workFlowTask);
		return string;
	}
	
	/*
	 * 试验室收样：选择工程 项目列表
	 */
	@ResponseBody
	@RequestMapping(value="api/samplesProjet/list",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String samplesProjetList (LabsFlowA labsFlowA) {
		String string = laboratoryService.samplesProjetList(labsFlowA);
		return string;
	}
	
	/**
	 * 查询工程详情
	 */
	@ResponseBody
	@RequestMapping(value="api/samplesProjet/search",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String samplesProjetSearch (LabsFlowA labsFlowA) {
		String string = laboratoryService.samplesProjetSearch(labsFlowA);
		return string;
	}
	
	/**
	 * 提交委托收样
	 */
	@ResponseBody
	@RequestMapping(value="api/entrustReceived/commit",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String entrustReceivedCommit (LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
		String string = laboratoryService.entrustReceivedCommit(labsFlowA,workFlowTask);
		return string;
	}
	
	/**
	 * 实验室 任务指派 详情 工程列表
	 */
	@ResponseBody
	@RequestMapping(value="api/projetDispatching/list",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String projetDispatching (LabsFlowA labsFlowA) {
		String string = laboratoryService.projetDispatching(labsFlowA);
		return string;
	}
	
	/**
	 * 根据工程名称查询工程详情
	 */
	@ResponseBody
	@RequestMapping(value="api/projetDispatching/search",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String projetDispatchingSearch (LabsFlowA labsFlowA) {
		String string = laboratoryService.projetDispatchingSearch(labsFlowA);
		return string;
	}
	
	/**
	 * 检测任务通知书完成 或者退回
	 */
	@ResponseBody
	@RequestMapping(value="api/detectionTask/Inform",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String detectionTaskInform (LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
		String string = laboratoryService.detectionTaskInform(labsFlowA,workFlowTask);
		return string;
	}
	
	/**
	 * 检测任务通知书退回之后再次提交
	 */
	@ResponseBody
	@RequestMapping(value="api/detectionTask/commit",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String detectionTaskCommit(LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
		String string = laboratoryService.detectionTaskCommit(labsFlowA,workFlowTask);
		return string;
	}
	
	/**
	 * 项目详情
	 */
	@ResponseBody
	@RequestMapping(value="api/detectionTask/detail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String detectionTaskDetail(LabsFlowA labsFlowA) {
		String string = laboratoryService.detectionTaskDetail(labsFlowA);
		return string;
	}
	
	/**
	 * 试验室报告详情
	 */
	@ResponseBody
	@RequestMapping(value="api/LabReport/detail",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String LabReportDetail(LabsFlowA labsFlowA) {
		String string = laboratoryService.LabReportDetail(labsFlowA);
		return string;
	}
	
	/**
	 * 试验室报告流程：提交审核 或者退回至试验修改
	 */
	@ResponseBody
	@RequestMapping(value="api/LabReport/SubmitOrModify",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String LabReportSubmitOrModify(LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
		String string = laboratoryService.LabReportSubmitOrModify(labsFlowA,workFlowTask);
		return string;
	}
	
	
	
	/**
	 * 试验室报告流程：提交审批 或者退回至审核
	 */
	@ResponseBody
	@RequestMapping(value="api/approve/SubmitOrModify",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String approveSubmitOrModify(LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
		String string = laboratoryService.approveSubmitOrModify(labsFlowA,workFlowTask);
		return string;
	}
	/**
	 *试验室报告流程： 出报告
	 * @param labsFlowA
	 * @param workFlowTask
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="api/report/Submit",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String reportSubmit(LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
		String string = laboratoryService.reportSubmit(labsFlowA,workFlowTask);
		return string;
	}
	
	/**
	 *试验室报告流程：试验修改
	 * @param labsFlowA
	 * @param workFlowTask
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="api/testTomModify/Submit",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String testTomModify(LabsFlowA labsFlowA,WorkFlowTask workFlowTask) {
		String string = laboratoryService.testTomModify(labsFlowA,workFlowTask);
		return string;
	}
	/**
	 * 试验修改的工程列表
	 * @param labsFlowA
	 * @param workFlowTask
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="api/testTomModify/List",method=RequestMethod.POST,produces="application/json;charset=utf-8")
	public String testTomModifyList(LabsFlowA labsFlowA) {
		String string = laboratoryService.testTomModifyList(labsFlowA);
		return string;
	}
}
